import cv2
import numpy as np

cap = cv2.VideoCapture(0)

bgr = np.uint8([[[165, 200, 250]]])
hsv_lower = cv2.cvtColor(bgr, cv2.COLOR_BGR2HSV)
[[[a,b,c]]] = hsv_lower
hsv_upper = np.array([[[a+20, 50, 250]]],np.uint8)

while True:
    ret, frame = cap.read()

    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    mask = cv2.inRange(hsv, hsv_lower, hsv_upper)

    res = cv2.bitwise_and(frame, frame, mask=mask)

    cv2.imshow("frame",frame)
    cv2.imshow("mask",mask)
    cv2.imshow("res",res)

    if cv2.waitKey(5) & 0xff == ord(" "):
        break
    pass

cap.release()
cv2.destroyAllWindows()